//
//  LSExponentSectionHeaderView.m
//  LookScore
//
//  Created by wws on 2018/3/21.
//  Copyright © 2018年 ChongQingXunTiCompany. All rights reserved.
//

#import "LSExponentSectionHeaderView.h"

@implementation LSExponentSectionHeaderView{
    UIButton * _btn;//返回按钮
    UILabel * _companyLabel;//公司名字
    UILabel * _hostLabel;//主队
    UILabel * _guestLabel;//客队
    UILabel * _concedePointsLabel;//让球
    
}

- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
       
        [self customView];
    }
    return self;
}

- (void)customView{
    
    _btn = [UIButton buttonWithType:UIButtonTypeCustom];
    [_btn setTitle:@"返回" forState:UIControlStateNormal];
    [_btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [_btn setBackgroundColor:LSButtonColor];
    _btn.titleLabel.font = LSFontSize12;
    [_btn addTarget:self action:@selector(backBtnClicked:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:_btn];
    
//    _btn.hidden = YES;
    _companyLabel = [[UILabel alloc] init];
    _companyLabel.text = @"公司";
    _companyLabel.font = LSFontSize12;
    _companyLabel.textColor = LSSubColor5D5D5D;
    _companyLabel.textAlignment = NSTextAlignmentCenter;
    [self addSubview:_companyLabel];
    
    _hostLabel = [[UILabel alloc] init];
    _hostLabel.text = @"主队";
    _hostLabel.textAlignment = NSTextAlignmentCenter;
    _hostLabel.font = LSFontSize12;
    _hostLabel.textColor = LSSubColor5D5D5D;
    [self addSubview:_hostLabel];
    
    
    _concedePointsLabel = [[UILabel alloc] init];
    _concedePointsLabel.text = @"让球";
    _concedePointsLabel.textAlignment = NSTextAlignmentCenter;
    _concedePointsLabel.font = LSFontSize12;
    _concedePointsLabel.textColor = LSSubColor5D5D5D;
    [self addSubview:_concedePointsLabel];
    
    _guestLabel = [[UILabel alloc] init];
    _guestLabel.text = @"客队";
    _guestLabel.textAlignment = NSTextAlignmentCenter;
    _guestLabel.font = LSFontSize12;
    _guestLabel.textColor = LSSubColor5D5D5D;
    [self addSubview:_guestLabel];
    
   
}

- (void)setType:(NSInteger)type{
    _type = type;
    if (type == 0) {
        _hostLabel.text = @"胜";
        _concedePointsLabel.text = @"平";
        _guestLabel.text = @"负";
    }else if (type == 1){
        
        _hostLabel.text = @"主队";
        _concedePointsLabel.text = @"让球";
        _guestLabel.text = @"客队";
    }else{
        _hostLabel.text = @"大球";
        _concedePointsLabel.text = @"盘口";
        _guestLabel.text = @"小球";
        
    }
    
}

- (void)setIsHiddening:(NSInteger)isHiddening{
    _isHiddening = isHiddening;
    if (_isHiddening == 0) {
        _btn.hidden = YES;
       _btn.sd_resetLayout
        .leftEqualToView(0)
        .topEqualToView(0)
        .widthRatioToView(self, 0.2)
        .heightRatioToView(self, 1);
        
        
        _guestLabel.sd_resetLayout
        .topEqualToView(0)
        .rightEqualToView(self)
        .widthIs((LSScreenWidth - 80)/4)
        .heightRatioToView(self, 1);
        _concedePointsLabel
        .sd_resetLayout.topEqualToView(0)
        .rightSpaceToView(_guestLabel, 0)
        .widthIs((LSScreenWidth - 80)/4)
        .heightRatioToView(self, 1);
        _hostLabel.sd_resetLayout
        .topEqualToView(0)
        .rightSpaceToView(_concedePointsLabel, 0)
        .heightRatioToView(self, 1)
        .widthIs((LSScreenWidth - 80)/4);
        _companyLabel.sd_resetLayout
        .topEqualToView(0)
        .leftEqualToView(self)
        .heightRatioToView(self, 1)
        .widthRatioToView(self, 0.2);
        _companyLabel.text = @"公司";
        
        
        
    }else{
        _btn.hidden = NO;
        _companyLabel.text = @"时间";
        
        _btn.sd_resetLayout.leftEqualToView(0).topEqualToView(0).widthRatioToView(self, 0.2).heightRatioToView(self, 1);
        _guestLabel.sd_resetLayout
        .topEqualToView(self)
        .rightSpaceToView(self, 0)
        .widthRatioToView(self, 0.2)
        .heightRatioToView(self, 1);
        _concedePointsLabel.sd_resetLayout
        .topEqualToView(self)
        .rightSpaceToView(_guestLabel, 0)
        .widthRatioToView(self, 0.2)
        .heightRatioToView(self, 1);
        _hostLabel.sd_resetLayout
        .topEqualToView(self)
        .rightSpaceToView(_concedePointsLabel, 0)
        .heightRatioToView(self, 1)
        .widthRatioToView(self, 0.2);
        _companyLabel.sd_resetLayout
        .topEqualToView(0)
        .leftSpaceToView(_btn, 0)
        .heightRatioToView(self, 1)
        .widthRatioToView(self, 0.2);
        
        
        
        
        
       
    }
    
   
}

- (void)backBtnClicked:(UIButton *)sender{
    
    if ([_delegate respondsToSelector:@selector(backBtnClicked:)]) {
        [_delegate backBtnClicked:sender];
    }
    
}
@end
